
#ifndef DYNAMICSCENE_H
#define DYNAMICSCENE_H

#include <BMap>
#include <BEvent>
#include <BScene>
#include <BFile>

#include <btConeShape.h>
#include <btBoxShape.h>
#include <btSphereShape.h>
#include <btCapsuleShape.h>
#include <btTriangleMesh.h>
#include <btCylinderShape.h>
#include <btBvhTriangleMeshShape.h>
#include <btCompoundShape.h>

#include <btCollisionConfiguration.h>
#include <btDbvtBroadphase.h>
#include <btRigidBody.h>
#include <btDiscreteDynamicsWorld.h>
#include <btPointConstraint.h>
#include <btHingeConstraint.h>
#include <btConeTwistConstraint.h>
#include <btSixdofConstraint.h>
#include <btSliderConstraint.h>
#include <btSixdofSpringConstraint.h>
#include <btUniversalConstraint.h>
#include <btHinge2Constraint.h>
#include <btGearConstraint.h>
#include <btFixedConstraint.h>
#include <btSequentialConstraintSolver.h>
#include <btRaycastVehicle.h>

using namespace BWE;

class DynamicScene : public BScene
{
public:
	DynamicScene();
	~DynamicScene();

protected:
	btConstraint* createTypedConstraint(BConstraint* constraint);
	btShape* createCollisionShape(BShape* shape);
	btRigidBody* createRigidBody(BNode* node, BPhysics* physics);

protected:
	void slotInsert(BObject* object, const BValue& value);
	void slotRemove(BObject* object, const BValue& value);
	void slotConstraintEnabled(BObject* object, const BValue& value);
	void slotConstraintChanged(BObject* object, const BValue& value);
	void slotPhysicsChanged(BObject* object, const BValue& value);

protected:
	virtual void update(double time) override;

private:
	btBroadphase*				_broadphase;
	btCollisionDispatcher*		_dispatcher;
	btConstraintSolver*			_solver;
	btDiscreteDynamicsWorld*	_dynamicsWorld;
	BMap<BShape*, btShape*>		_collisionShapeMap;

};

#endif
